﻿#region << 文件说明 >>
/*----------------------------------------------------------------
 * 命名空间：Vampirewal.Core.Attributes
 * 唯一标识：a2fcb868-8de7-4f84-a508-a6044abc7784
 * 文件名：PropertyControlAttributes
 * 
 * 创建者：杨程
 * 电子邮箱：235160615@qq.com
 * 创建时间：2024/5/30 10:44:19
 * 版本：V1.0.0
 * 描述：
 *
 * ----------------------------------------------------------------
 * 修改人：
 * 时间：
 * 修改说明：
 *
 * 版本：V1.0.1
 *----------------------------------------------------------------*/
#endregion << 文件说明 >>

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


namespace Vampirewal.Core.Attributes;

/// <summary>
/// 属性面板特性
/// </summary>
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]
public class PropertyInfoPanelAttribute : Attribute
{
    /// <summary>
    /// 每行的列数
    /// </summary>
    public int Columns { get; set; } = 1;

    public double MarginLeft { get; set; } = 0;

    public double MarginTop {  get; set; } = 2;

    public double MarginRight {  get; set; } = 0;

    public double MarginBottom {  get; set; } = 0;
}


/// <summary>
/// 属性信息特性
/// </summary>
//[AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]
public class PropertyInfoAttribute : Attribute
{
    /// <summary>
    /// 
    /// </summary>
    /// <param name="title">标题</param>
    /// <param name="titleWidth">标题宽度</param>
    /// <param name="groupName">分组名称</param>
    /// <param name="sortIndex">排序序号</param>
    /// <param name="isReadOnly">是否只读</param>
    public PropertyInfoAttribute(string title, double titleWidth, string groupName,int sortIndex, bool isReadOnly = false)
    {
        Title=title;
        TitleWidth=titleWidth;
        GroupName =groupName;
        SortIndex=sortIndex;
        IsReadOnly=isReadOnly;
    }

    /// <summary>
    /// 标题
    /// </summary>
    public string Title { get; set; }

    /// <summary>
    /// 标题宽度
    /// </summary>
    public double TitleWidth { get; set; }

    /// <summary>
    /// 分组名称
    /// </summary>
    public string GroupName { get; set; }

    /// <summary>
    /// 排序序号
    /// </summary>
    public int SortIndex { get; set; }

    /// <summary>
    /// 是否只读(默认false)
    /// </summary>
    public bool IsReadOnly { get; set; }
}

/// <summary>
/// 文本属性信息特性
/// </summary>
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]
public class TextPropertyInfoAttribute: PropertyInfoAttribute
{
    /// <summary>
    /// 
    /// </summary>
    /// <param name="title"></param>
    /// <param name="titleWidth"></param>
    /// <param name="groupName"></param>
    /// <param name="sortIndex"></param>
    public TextPropertyInfoAttribute(string title, double titleWidth, string groupName, int sortIndex) :base(title, titleWidth, groupName, sortIndex)
    {

    }

    
}

/// <summary>
/// 数字属性信息特性
/// </summary>
public class NumberTextPropertyInfoAttribute : PropertyInfoAttribute
{
    /// <summary>
    /// 
    /// </summary>
    /// <param name="title"></param>
    /// <param name="titleWidth"></param>
    /// <param name="groupName"></param>
    /// <param name="sortIndex"></param>
    /// <param name="regexType"></param>
    public NumberTextPropertyInfoAttribute(string title, double titleWidth, string groupName, int sortIndex, RegexTextType regexType) : base(title, titleWidth, groupName, sortIndex)
    {
        RegexType=regexType;
    }

    /// <summary>
    /// 验证类型
    /// </summary>
    public RegexTextType RegexType { get;private set; }
}

/// <summary>
/// 属性正则验证类型
/// </summary>
public enum RegexTextType
{
    /// <summary>
    /// 验证数字
    /// </summary>
    [Description("^[0-9]*$")]
    Number,

    /// <summary>
    /// 验证非零的正整数
    /// </summary>
    [Description(@"^\+?[1-9][0-9]*$")]
    Integer,

    /// <summary>
    /// 2位小数正实数
    /// </summary>
    [Description("^[0-9]+(.[0-9]{1,2})?$")]
    Dec2,

    /// <summary>
    /// 1-100的正实数
    /// </summary>
    [Description("^(100(\\.00?)?|[1-9]?\\d(\\.\\d\\d?)?|0?\\.\\d\\d?)$")]
    Dec1To100,

    /// <summary>
    /// 1-100的实数
    /// </summary>
    [Description(@"^-?\(100(\.00?)?|[1-9]?\d(\.\d\d?)?|0?\.\d\d?)$")]
    Dec1To100Ex,

    /// <summary>
    /// 2位小数(正负数)
    /// </summary>
    [Description("^-?\\d+(.\\d{1,2})?$")]
    Dec2Ex,

    /// <summary>
    /// 4位小数正实数
    /// </summary>
    [Description("^[0-9]+(.[0-9]{1,4})?$")]
    Dec4,

    /// <summary>
    /// 4位小数(正负数)
    /// </summary>
    [Description("^-?\\d+(.\\d{1,4})?$")]
    Dec4Ex,

    /// <summary>
    /// 验证正负数，保留2位小数
    /// </summary>
    [Description("^-?\\d+(\\.\\d{1,2})?$")]
    Dec5,

    /// <summary>
    /// 6位小数正实数
    /// </summary>
    [Description("^[0-9]+(.[0-9]{1,6})?$")]
    Dec6,

    /// <summary>
    /// 验证0-100的正数，保留4位小数
    /// </summary>
    [Description(@"^(?:100(?:\.0{1,4})?|\d{1,2}(?:\.\d{1,4})?)$")]
    Dec7,

    /// <summary>
    /// 验证-100到100，保留两位小数
    /// </summary>
    [Description(@"^(-?)(0*)(0(\.\d{1,2})?|[1-9]\d?(\.\d{1,2})?|100(\.0{1,2})?)$")]
    DecM100To100,

    /// <summary>
    /// 验证0到100，保留两位小数
    /// </summary>
    [Description(@"^(0*)(0(\.\d{1,2})?|[1-9]\d?(\.\d{1,2})?|100(\.0{1,2})?)$")]
    Dec0To100,

    /// <summary>
    /// 验证身份证号
    /// </summary>
    [Description(@"^\d{15}|\d{}18$")]
    IDCart,

    /// <summary>
    /// 验证电话号码
    /// </summary>
    [Description(@"^(\(\d{3,4}$|\d{3,4}-)?\d{7,8}$")]
    Tel,

    /// <summary>
    /// 0到100的正整数
    /// </summary>
    [Description(@"^(?:[1-9]|[1-9]\d|100)$")]
    Dec8,

    /// <summary>
    /// 0到100的正整数
    /// </summary>
    [Description(@"^(?:100|\d{1,2})$")]
    Dec9
}


